package org.example.caltax;

import java.util.ArrayList;
import java.util.List;
public class TaxMain {
    public static int a;
    public static void main(String[] args) {
        System.out.println(a);
        TaxMain taxMain = new TaxMain();
        System.out.println(taxMain.a);
        System.out.println(TaxMain.a);
        TaxSection taxSection1 = new TaxSection();
//        TaxSection taxSection2=taxSection1;
        TaxSection taxSection2=new TaxSection();
        System.out.println(taxSection1);

        String a="";
        //1.准备好数据，准备8条TaxSection对象，放入到一个集合里面，List
        List<TaxSection> taxSectionList = new ArrayList<>();
        taxSectionList.add(new TaxSection(0, 5000, 0.0));
        taxSectionList.add(new TaxSection(5000, 8000, 0.03));
        taxSectionList.add(new TaxSection(8000, 17000, 0.1));
        taxSectionList.add(new TaxSection(17000, 30000, 0.2));
        taxSectionList.add(new TaxSection(30000, 40000, 0.25));
        taxSectionList.add(new TaxSection(40000, 60000, 0.3));
        taxSectionList.add(new TaxSection(60000, 85000, 0.35));
        taxSectionList.add(new TaxSection(85000, Double.MAX_VALUE, 0.45));
        //2.遍历list集合，分别调用TaxSection对象的calTax方法
        //3.把八个方法的返回结果求和就是你要交的税费
        double result = 0;
        for(TaxSection taxSection:taxSectionList){
            result += taxSection.calTax(10000);
        }
//        double result = taxSectionList.stream()
//                .mapToDouble(taxSection->taxSection.calTax(10000))
//                .sum();
        System.out.println(result);
    }
}
